package com.cloudkinto.enumType.order.outbound;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.cloudkinto.common.utils.dict.StaticDict;
import com.cloudkinto.vo.common.CommonKvVo;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Objects;

/**
 * @author long
 */

public enum SalesPlatformEnum implements IEnum<Integer> {

    /**
     *
     */
//    one(1, "AliExpress", ""),
    two(2, "Amazon", StaticDict.Store_PlatformCode.Amazon.getValue()),
    three(3, "eBay", ""),
//    four(4, "Lazada", ""),
//    five(5, "Shopee", ""),
    six(6, "shopify", StaticDict.Store_PlatformCode.Shopify.getValue()),
    seven(7, "Walmart", ""),
    eight(8, "Wayfair", ""),
//    nine(9, "Wish", ""),
//    ten(10, "MercadoLibre", ""),
//    eleven(11, "WooCommerce", ""),
//    twelve(12, "HomeDepot", ""),
//    thirteen(13, "Overstock", ""),
//    fourteen(14, "Amazon VC", ""),
//    fifteen(15, "Joom", ""),
//    sixteen(16, "Tophatter", ""),
//    seventeen(17, "UeeShop", ""),
//    eighteen(18, "Shoplazza", ""),
//    nineteen(19, "Jumia", ""),
//    twenty(20, "Tiktok", ""),
//    twentyOne(21, "Xshoppy", ""),
//    twentyTwo(22, "Shopline", ""),
//    twentyThree(23, "Allegro", ""),
//    twentyFour(24, "Daraz", ""),
//    twentyFive(25, "Etsy", ""),
//    twentySix(26, "Allvalue", ""),
//    twentySeven(27, "Fnac", ""),
    twentyEight(28, "Rakuten", StaticDict.Store_PlatformCode.Rakuten.getValue()),
//    twentyNine(29, "Shoplus", ""),
//    thirty(30, "Sears", ""),
//    thirtyOne(31, "Shein", ""),
//    thirtyTwo(32, "Lowe's", ""),
//    thirtyThree(33, "Target", ""),
//    thirtyFour(34, "Temu", ""),
//    thirtyFive(35, "Customer Service", ""),
//    thirtySix(36, "Teapplix", ""),
//    thirtySeven(37, "B2B", ""),
    thirtyEight(38, "Yahoo", StaticDict.Store_PlatformCode.Yahoo.getValue()),
//    thirtyNine(39, "Coupany", ""),
//    fourty(40, "Ozon", ""),
//    fourtyOne(41, "Wildberries", ""),
//    fourtyTwo(42, "Cdiscount", ""),
//    fourtyThree(43, "Otto", ""),
//    fourtyFour(44, "Newegg", ""),
//    fourtyFive(45, "Kohl's", ""),
//    fourtySix(46, "Macy's", ""),
    fourtySeven(47, "Other", ""),
    fourtyEight(48, "Makeshop", StaticDict.Store_PlatformCode.Makeshop.getValue()),
    fourtyNine(49, "Qoo10", StaticDict.Store_PlatformCode.Qoo10.getValue());


    private final Integer code;

    private final String name;
    @ApiModelProperty("平台订单那边的代码表")
    private final String platCode;

    SalesPlatformEnum(Integer code, String name, String platCode) {
        this.code = code;
        this.name = name;
        this.platCode = platCode;
    }

    @Override
    public Integer getValue() {
        return code;
    }


    public static Integer getCodeByPlatCode(String platCode) {
        if (StringUtils.isBlank(platCode)) {
            return fourtySeven.getValue();
        }
        for (SalesPlatformEnum value : values()) {
            if (Objects.equals(value.platCode, platCode)) {
                return value.getValue();
            }
        }
        return fourtySeven.getValue();
    }


    public static ArrayList<CommonKvVo> getSalesPlatformList() {
        ArrayList<CommonKvVo> list = new ArrayList<>();
        for (SalesPlatformEnum inboundType : values()) {
            list.add(
                    CommonKvVo.builder()
                            .label(inboundType.name)
                            .value(inboundType.getValue())
                            .build()
            );
        }
        return list;
    }

    public static Integer getValByName(String name) {
        if (StrUtil.isEmpty(name)) {
            return null;
        }
        for (SalesPlatformEnum inboundType : values()) {
            if (inboundType.name.equals(name)) {
                return inboundType.getValue();
            }
        }
        return null;
    }

    public static String getNameByVal(Integer val) {
        if (val == null) {
            return "";
        }
        for (SalesPlatformEnum inboundType : values()) {
            if (inboundType.getValue().equals(val)) {
                return inboundType.name;
            }
        }
        return "";
    }
}
